package cn.ecut.service.role;

import cn.ecut.dao.BaseDao;
import cn.ecut.dao.role.RoleDao;
import cn.ecut.dao.role.RoleDaoImpl;
import cn.ecut.pojo.Role;
import org.junit.Test;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

/**
 * @Author ruanxin
 */
public class RoleServiceImpl implements RoleService {
    private RoleDao roleDao;

    public RoleServiceImpl() {
        roleDao = new RoleDaoImpl();
    }

    @Override
    public List<Role> getRoleList() {
        Connection connection = null;
        List<Role> roleList = null;

        try {
            connection = BaseDao.getConnection();
            roleList = roleDao.getRoleList(connection);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        } finally {
            BaseDao.close(connection, null, null);
        }

        return roleList;
    }

}
